package hoowin.app.wsnd.service;

import java.util.Date;

import hoowin.app.wsnd.dao.IWsndUserDao;
import hoowin.app.wsnd.model.WsndUser;
import hoowin.basic.util.Trans;

public class WsndUserService {
	private IWsndUserDao wsndUserDao;
	
	public String addWsndUser(int userId, String nationality, int month, int day, int year){
		WsndUser wsndUser = new WsndUser();
		wsndUser.setId(userId);
		wsndUser.setNationality(nationality);
		String birth = year+"-";
		if(month<10)birth+="0";
		birth+=month+"-";
		if(day<10)birth+="0";
		birth+=day;
		Date birthday = Trans.stringToSimpledate(birth);
		if(birthday==null)return "exception.1001";
		wsndUser.setBirthday(birthday);
		if(wsndUserDao.addWsndUser(wsndUser))return "success";
		else return "error.1300";
	}

	public void setWsndUserDao(IWsndUserDao wsndUserDao) {
		this.wsndUserDao = wsndUserDao;
	}

	public IWsndUserDao getWsndUserDao() {
		return wsndUserDao;
	}
}
